﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:Rule18_Core="clr-namespace:Rule18.Core;assembly=Rule18.Core" 
        x:Class="Rule18.MainWindow"
        xmlns:SiSoft="clr-namespace:SiSoft.Samples.ReorderableListBoxSample"
        Title="Rule 18" Height="430" Width="860" Icon="/Rule18;component/Images/favorites.png" Closing="Window_Closing" mc:Ignorable="d" Loaded="Window_Loaded" ResizeMode="CanResizeWithGrip" WindowStartupLocation="CenterScreen" MinWidth="860" MinHeight="430">
    <Window.Resources>
        <DataTemplate x:Key="clipTemplate">
            <DataTemplate.Resources>
                <Storyboard x:Key="EnableTextEditor">
                    <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" Storyboard.TargetName="textBlock">
                        <EasingColorKeyFrame KeyTime="0:0:0.5" Value="#E1FFFFFF">
                            <EasingColorKeyFrame.EasingFunction>
                                <BackEase EasingMode="EaseOut"/>
                            </EasingColorKeyFrame.EasingFunction>
                        </EasingColorKeyFrame>
                    </ColorAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="textBlock">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="175"/>
                    </DoubleAnimationUsingKeyFrames>
                    <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Height)" Storyboard.TargetName="stackPanel">
                        <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="175"/>
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </DataTemplate.Resources>
            <Grid x:Name="stackPanel" Height="28">
                <Grid.ContextMenu>
                    <ContextMenu>
                        <MenuItem Header="Delete" ToolTip="Remove the clip" CommandParameter="{Binding Id}" Click="DeleteMenuItem_Click" />
                    </ContextMenu>
                </Grid.ContextMenu>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="16"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="180"/>
                    <ColumnDefinition Width="24"/>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" Margin="0,6,2,6" Source="arrow-move.png" ToolTip="Reorder" VerticalAlignment="Top" />
                <TextBox Grid.Column="1" x:Name="textBlock" Tag="{Binding Id}" Height="26" Margin="0,1,2,1" TextWrapping="Wrap" HorizontalAlignment="Stretch" Text="{Binding WideDisplayText, Mode=OneWay}" VerticalAlignment="Stretch" MinWidth="375" Background="#33FFFFFF" ToolTip="{Binding Text}" RenderTransformOrigin="0.5,0.5" IsReadOnly="True" GotFocus="textBlock_GotFocus" LostFocus="textBlock_LostFocus">
                    <TextBox.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                        </TransformGroup>
                    </TextBox.RenderTransform>
                </TextBox>
                <Button Grid.Column="2" VerticalAlignment="Top" BorderBrush="#FF891313" Background="{x:Null}" Content="{Binding Key, Mode=OneWay}" Foreground="Black" Margin="0" ToolTip="Click here to change hotkey." CommandParameter="{Binding Id}" Click="HotkeyChangeButton_Click" Height="28" />
                <Button Grid.Column="3" VerticalAlignment="Top" CommandParameter="{Binding Id}" BorderBrush="{x:Null}" Background="{x:Null}" Foreground="{x:Null}" Height="24" Margin="2,0,0,0" ToolTip="Delete" Click="DeleteButton_Click">
                    <Image Margin="0" Source="cross-octagon-frame.png" Stretch="None" ToolTip="Delete" Width="16"/>
                </Button>
            </Grid>
            <DataTemplate.Triggers>
                <EventTrigger RoutedEvent="FocusManager.GotFocus" SourceName="textBlock">
                    <BeginStoryboard x:Name="EnableTextEditor_BeginStoryboard" Storyboard="{StaticResource EnableTextEditor}"/>
                </EventTrigger>
                <EventTrigger RoutedEvent="FocusManager.LostFocus" SourceName="textBlock">
                    <RemoveStoryboard BeginStoryboardName="EnableTextEditor_BeginStoryboard"/>
                </EventTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>        
    </Window.Resources>
    <!-- Form -->
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#0D000000" Offset="0.766" />
                <GradientStop Color="#51909090" Offset="0.286" />
                <GradientStop Color="#8B909090" Offset="1" />
            </LinearGradientBrush>
        </Grid.Background>
        <Grid HorizontalAlignment="Left" Margin="8,0,0,0" Width="204" Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Label Grid.Row="0" Content="Rule 18" Height="47" Margin="0,0,0,8" x:Name="label1" FontSize="32" FontWeight="Bold" FontFamily="Fonts/#Bauhaus 93" Foreground="#FFC61313" >
                <Label.Effect>
                    <DropShadowEffect/>
                </Label.Effect>
            </Label>
            <StackPanel Grid.Row="1" HorizontalAlignment="Center" Height="120" Margin="0" Orientation="Vertical" VerticalAlignment="Center" d:LayoutOverrides="Width">
                <StackPanel Orientation="Horizontal" Margin="1">
                    <Button FontSize="16" FontWeight="Bold" Height="60" x:Name="addClipButton" VerticalAlignment="Top" Width="60" Click="addClipButton_Click" Background="{x:Null}" BorderBrush="#FF891313" Foreground="{x:Null}" Margin="0,0,8,0" ToolTip="Add clip to set">
                        <Image Source="/Rule18;component/Images/add_48.png" HorizontalAlignment="Center" Height="48" VerticalAlignment="Center" Width="48"/>
                    </Button>
                </StackPanel>
                <StackPanel Orientation="Horizontal" Margin="1">
                    <Button x:Name="loadSetButton" Width="60" FontSize="16" FontWeight="Bold" Click="loadSetButton_Click" Background="{x:Null}" BorderBrush="#FF891313" Margin="0,0,8,0" ToolTip="Open set">
                        <Image Source="box_download_48.png" HorizontalAlignment="Center" Height="48" VerticalAlignment="Center" Width="48"/>
                    </Button>
                    <Button Margin="0,0,8,0" x:Name="saveSetButton" Width="60" FontSize="16" FontWeight="Bold" Click="saveSetButton_Click" Background="{x:Null}" BorderBrush="#FF891313" Foreground="{x:Null}" ToolTip="Save set">
                        <Image Source="/Rule18;component/Images/floppy_disk_48.png" HorizontalAlignment="Center" Height="48" VerticalAlignment="Center" Width="48"/>
                    </Button>
                    <Button Margin="0,0,8,0" x:Name="newSetButton" Width="60" FontSize="16" FontWeight="Bold" Background="{x:Null}" BorderBrush="#FF891313" Foreground="{x:Null}" ToolTip="New set" Click="newSetButton_Click">
                        <Image Source="/Rule18;component/Images/paper_48.png" HorizontalAlignment="Center" Height="48" VerticalAlignment="Center" Width="48" SnapsToDevicePixels="True" />
                    </Button>
                </StackPanel>
            </StackPanel>
            <TextBlock Grid.Row="2" Height="163" x:Name="hintTextBlock" VerticalAlignment="Top" TextWrapping="Wrap" Foreground="#A1000000" Margin="0,8,0,0" />
            <StackPanel Grid.Row="3" Orientation="Vertical">
                <TextBlock x:Name="linkTextBlock" Text="Help? New Versions? Discussion?" Foreground="#FF000076" Cursor="Hand" MouseLeftButtonUp="linkTextBlock_MouseLeftButtonUp" TextAlignment="Center" Margin="0,4,0,0" />
                <TextBlock x:Name="versionTextBlock" Text="ver 0.0.0.0" Foreground="#FF838383" TextAlignment="Center" Margin="0,4,0,0" />
            </StackPanel>
        </Grid>
        <SiSoft:ReorderableListBox HorizontalContentAlignment="Stretch" Grid.Column="1" Margin="4,0,0,0" x:Name="clipsListBox" Background="#58FFFFFF" BorderBrush="#FF891313" ItemTemplate="{DynamicResource clipTemplate}" KeyUp="clipsListBox_KeyUp" ItemsReordered="clipsListBox_ItemsReordered" MinWidth="630" />
    </Grid>
</Window>
